<template>
	<view>
		<scroll-view class="form">
			<view class="text-card">
				<view class="card-row" v-for="item in form_rows" :key="item.label">
					<view class="row-label w30">{{item.label}}</view>
					<view class="row-content w70">{{item.value}}</view>
				</view>
				<view class="card-row">
					<view class="row-label w30">申报表</view>
					<view class="row-content w70">
						<image v-for="src in auser.images1Full" :src="src" mode="aspectFit" @click="clickImg" :data-url="src"></image>
					</view>
				</view>
				<view class="card-row">
					<view class="row-label w30">承诺书</view>
					<view class="row-content w70">
						<image v-for="src in auser.images4Full" :src="src" mode="aspectFit" @click="clickImg" :data-url="src"></image>
					</view>
				</view>
				<view class="card-row">
					<view class="row-label w30">营业执照</view>
					<view class="row-content w70">
						<image v-for="src in auser.images2Full" :src="src" mode="aspectFit" @click="clickImg" :data-url="src"></image>
					</view>
				</view>
				<view class="card-row">
					<view class="row-label w30">食品经营许可证</view>
					<view class="row-content w70">
						<image v-for="src in auser.images3Full" :src="src" mode="aspectFit" @click="clickImg" :data-url="src"></image>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageDomain: this.$api.imageDomain,
				auser: {},
				form_rows: {}
			}
		},
		onLoad(options) {
			this.auser = JSON.parse(decodeURIComponent(options.auser));
			this.initRows();
		},
		methods: {
			initRows(){				
				if(!this.auser) return false;
				this.form_rows = [
					{
						label: '企业名称',
						value: this.auser.username
					},{
						label: '社会统一代码',
						value: this.auser.userno
					},{
						label: '许可证号',
						value: this.auser.xukezhenghao
					},{
						label: '经营地址',
						value: this.auser.jingyingdizhi
					},{
						label: '法人',
						value: this.auser.faren
					},{
						label: '法人电话',
						value: this.auser.farentel
					},{
						label: '联系人',
						value: this.auser.lianxiren
					},{
						label: '联系人电话',
						value: this.auser.lianxirentel
					},{
						label: '监管机关',
						value: this.auser.jianguanjiguan
					},{
						label: '监管机关电话',
						value: this.auser.jianguanjiguantel
					},{
						label: '单位介绍',
						value: this.auser.danweijieshao
					}
				]
				
				for(let i=1; i<=4; i++){
					if(this.auser['images' + i]){
						this.auser['images' + i + 'Full'] = this.auser['images' + i].split(',').map(item => this.$api.imageDomain + item)
					}
				}
				// console.log('auser', this.auser)
			},
			clickImg(e){
				let url = e.target.dataset.url	
				let urls = [];
				urls.push(url)
				uni.previewImage({
					urls
				});
			}	
		}
	}
</script>

<style>
	.m-tag{
		position: absolute;
		top: 30px;
		bottom: 20px;
		left: 0upx;
		right: 0upx;
		margin: auto;
		width: 150upx;
		transform: rotate(15deg);
		letter-spacing: 10px;
		font-weight: 700;
	}
	.text-card{
		position: relative;
		font-size: 1.2em;
	}
	.card-row {
		border-bottom: solid 1upx #007AFF;
		align-items: center;
		padding: 10upx 20upx 20upx 20upx;
	}
	.row-content image {
		width: 150upx;
		height: 150upx;
	}
</style>
